﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FrienDev.Data;

namespace FrienDev.BusinessRules
{
    public class DictionaryRules
    {
        public static DictionaryRules Instance = new DictionaryRules();

        private FrienDevDataContext m_DataContext = FrienDevDataContext.Instance;

        private DictionaryRules()
        {
        }

         /// <summary>
        /// 得到公司类型、行业类型等
        /// </summary>
        /// <param name="objecttype"></param>
        /// <returns></returns>
        public IEnumerable<Dictionary> GetObjectTypes(string objecttype)
        {
            IEnumerable<Dictionary> dictionaries = from dic in m_DataContext.Dictionaries
                                                   where dic.ObjectType.ToString().Trim() == objecttype.Trim()
                                                   select dic;
            return dictionaries;
        }

        /// <summary>
        /// 得到技术类型
        /// </summary>
        /// <param name="technologytype"></param>
        /// <returns></returns>
        public IEnumerable<Technology> GetTechnologies(string technologytype)
        {
            IEnumerable<Technology> technologies = from tec in m_DataContext.Technologies
                                                   where tec.TechnologyType.ToString().Trim() == technologytype.Trim()
                                                   select tec;
            return technologies;
        }

        /// <summary>
        /// 得到技术名称ByID
        /// </summary>
        /// <param name="technologyid"></param>
        /// <returns></returns>
        public string GetTechnologyValue(int technologyid)
        {
            IEnumerable<Technology> technologies = from tec in m_DataContext.Technologies
                                                   where tec.TechnologyID == technologyid
                                                   select tec;
            Technology technology = technologies.SingleOrDefault();
            return technology.TechnologyValue;
        }
    }
}
